package rickyGame.game.action
{
	import ricky.game.Actor;
	import ricky.game.action.Act2D;
	
	import rickyGame.model.*;
	import rickyGame.model.config.*;
	import ricky.game.Actor2D;
	import rickyGame.game.GameState;
	import rickyGame.game.PetObject;
	import rickyGame.game.action.ActionHelper;
	import rickyGame.game.action.ai.AutoAttackAi;
	import rickyGame.game.action.ai.SeekAi;
	import rickyGame.game.skill.SkillData;
	
	/**
	 * 召唤宠物
	 */
	public class CallPetAct extends Act2D
	{
		public function CallPetAct(actor:Actor,skill:SkillData)
		{
			super(actor);
			_skill=skill;
		}
		
		
		override public function begin():void
		{
			var x:Number=actor.graphic.x;
			var y:Number=actor.graphic.y;

			var unit:Unit= ConfigUnitHelper.getHeroConfig(_skill.parameter);
			if(unit)
			{
				var petObj:PetObject=new PetObject(actor);
				petObj.graphic.x=x;
				petObj.graphic.y=y;
				petObj.load(unit);
				petObj.direction=Actor2D(actor).direction;
				petObj.loadProperty(20);
				petObj.group=actor.group;
				petObj.defaultAct=new SeekAi(petObj,actor);
				petObj.addAct(new AutoAttackAi(petObj));
				GameState.inst.sceneManager.addGameObject(petObj);
			}
			this.complete();
		}
		
		override public function dispose():void
		{
			super.dispose();
			_skill=null;
		}
		//
		
		private var _skill:SkillData
	}
}